home *** CD-ROM | disk | FTP | other *** search
- /* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
- * Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
- * Permission to use and distribute this software and its
- * documentation for noncommercial use and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation. It is not allowed to sell this software in
- * any way. This software is not public domain.
- */
-
-
- int RGB_Maximum1=1023;
-
-
- int RGB_F_LL=1391;
- int RGB_F_C1=2271;
- int RGB_O_C1=-353784;
- int RGB_F_C2=1865;
- int RGB_O_C2=-255023;
- int RGB_F_G1=-441;
- int RGB_F_G2=-949;
- int RGB_O_G =199313;
-
-
- static int T_L[256],T_R[256],T_G[256],T_g[256],T_B[256];
-
-
- void
- pcd_to_rgb(
- unsigned char *pl,
- unsigned char *pc1,
- unsigned char *pc2,
- unsigned char *prgb,
- int n
- )
- {
- int red, green, blue;
- int L;
- static int init = 0;
-
- if (! init)
- {
- int i;
-
- for (i = 0; i < 256; i++)
- {
- T_L[i] = i * RGB_F_LL;
- T_R[i] = i * RGB_F_C2 + RGB_O_C2;
- T_G[i] = i * RGB_F_G1;
- T_g[i] = i * RGB_F_G2 + RGB_O_G;
- T_B[i] = i * RGB_F_C1 + RGB_O_C1;
- }
- init = 1;
- }
-
- while (--n >= 0)
- {
- L = T_L[*pl];
- red = (L + T_R[*pc2] ) >> 10;
- green= (L + T_G[*pc1] + T_g[*pc2] ) >> 10;
- blue = (L + T_B[*pc1] ) >> 10;
-
- prgb[0] = (red & ~0xff) ? (red < 0 ? 0 : 255) : red;
- prgb[1] = (green & ~0xff) ? (green < 0 ? 0 : 255) : green;
- prgb[2] = (blue & ~0xff) ? (blue < 0 ? 0 : 255) : blue ;
-
- prgb += 3;
- pl++;
- pc1++;
- pc2++;
- }
- }
-